/**
 * 登录模块，提供登录相关业务功能
 * 
 * @Date: 2015-6-16
 * @author: Jackson wang
 * @version: 1.0
 * @since: 1.0
 */
define(["jquery","formServ","ajaxServ","msgServ","treegridServ","sysmanMain","tabServ"], 
	function($,formServ,ajaxServ,msgServ,treegridServ,sysmanMain,tabServ) {

	'use strict';

	var clickUrl = '/flowDefinition/getLastVersionList.action'
    var private_method = {
    	//初始化组件对象
    	init:function(_options){
    		if (window.console) {
    		console.info('workduties modules gets ready and  are loaded.');
    		}
    		
			private_method.bindBtnEvent();
			$.messager.progress('close');
    	},
    	
    	
    	
    	//绑定按钮事件
		bindBtnEvent:function(){
			// 绑定按钮事件
			var btn = $('#div-workduties a.work-btn')
			$(btn).unbind('click');
			$(btn).bind('click', private_method.function_btn_listenner)			
						
		},
    	
		
		//功能按钮监听函数
		function_btn_listenner:function(e){
			
			var _text = event.currentTarget.innerText;
			if(_text){
				_text = $.trim(_text)
			}
			var _url = '/'+sysmanMain.getRootPath()+'/permission/query/getOneByField.action'
			//获取配置信息
			$.ajax({
				url:_url,
				data:{field:'name',fieldVal:_text},
				type:'post',
				success:private_method.addConfig
			})
			
		},
		
		addConfig:function(data){
			
			if(data && data.fullBizcode){
				//add config to sysmain
				sysmanMain.setModuConf(data.fullBizcode,data);
				sysmanMain.setModuleNameConfig(data.name,data.fullBizcode)				
				sysmanMain.setCurrentModuConfig(data)
				//open tab
				var _url ='/'+sysmanMain.getRootPath()+ data.pageURL
				var _tabParam = {target:$('#centerTabs'),tabUrl:_url,title:data.name}
				tabServ.addHrefTab(_tabParam)
			}else{
				msgServ.Msgslide('模块配置信息异常，请联系系统管理员')
			}
			
			//set current module config
			
		}
		
		
	}
	
	var public_method={
		//销毁方法，释放绑定事件及变量定义
		destory:function(){
			var btn = $('#div-workduties a.work-btn')
			$(btn).unbind('click');
				
		},
		//初始化页面
		init:function(doc){
			private_method.init(doc)
		}
		
	}
		
		
	return public_method;

	

});